/**
 * 
 */
package demo.tellurium.test.cqp;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import demo.tellurium.framework.BaseTelluriumJUnitTestCase;
import demo.tellurium.module.cqp.CQPLoginModule;
import demo.tellurium.module.cqp.CQPProfileModule;

/**
 * @author roger.xu
 * 
 */
public class ProductNameJUnitTestCase extends BaseTelluriumJUnitTestCase {
    private static CQPLoginModule cqpLogin;
    private static CQPProfileModule cqpProfile;

    @BeforeClass
    public static void initUi() {
        cqpLogin = new CQPLoginModule();
        cqpLogin.defineUi();

        cqpProfile = new CQPProfileModule();
        cqpProfile.defineUi();
    }

    @Before
    public void waitDelay() {
        waitingDelay();
    }

    @Test
    public void connectTo() {
        String contextUrl = getProperty("cqp.context.url");
        String pagePath = getProperty(CQPProfileModule.PATH_KEY);
        String url = String.format("%s/%s", contextUrl, pagePath);
        connectUrl(url);
    }

    @Test
    public void testLogin() {
        console.debug("[testLogin]");
        // cqpLogin.doAdminLogin();
        String username = getProperty("cqp.login.username");
        String password = getProperty("cqp.login.password");
        cqpLogin.doLogin(username, password);
        pauseSec(3);
    }

    @Test
    public void testProductName() {
        pauseSec(3);
        for (int i = 0; i < 1; i++) {
            run();
        }
    }

    private void run() {
        console.debug("[testOfferingType]");
        cqpProfile.doSelectOfferingType(1);
        console.debug("[testDivision]");
        cqpProfile.doSelectDivision(-1);
        pauseSec(2);
        console.debug("[testProductName]");
        cqpProfile.doTypeSelectProductName("a", -1);
        console.debug("[testProductType]");
        cqpProfile.doSelectProductType(-1);
        console.debug("[AssesssmentType]");
        cqpProfile.doClickAssessmentTypeMidMarket();
        pauseSec(1);
    }
}
